-
Notifications
You must be signed in to change notification settings - Fork 12
Set ethernet and wifi MAC address #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The openwrt image must be changed:
|
|| check_otp_version(VERSION_REG1_OFFSET)) | ||
return; | ||
|
||
node = fdt_path_offset(blob, "/uccp@18480000"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we add an alias for Wi-Fi node as we do for ethernet, as change in dts node name will require a change in the code ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
return; | ||
} | ||
|
||
/* Set Wifi STA and AP MAC address in device tree */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check whether the addresses are valid before writing ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
return -1; | ||
} | ||
|
||
if (version != 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we keep the 1 as macro ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure this arch will work from a backwards compatibility point of view. Imagine we had to release a version 2 OTP layout that was a superset of version 1. The code change should be as simple as here is the extra stuff to read if you see version 2. i.e. it should hit the version 1 code already here (not duplicate it) and then carry on to any further versions.
We would never change layouts already released meaning you can always assume a new version is a superset. So based on this how about we drop this file and just wrap the read_otp calls in conditions of greater than version N (in this case 1)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
#ifdef CONFIG_WINBOND_OTP | ||
if (!is_valid_ethaddr(mac_addr) | ||
&& !check_otp_version(VERSION_REG0_OFFSET)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this logical AND to the end of above line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would conflict with the coding style guidelines of u-boot.
else | ||
printf("Could not read MAC address from OTP\n"); | ||
} | ||
#endif | ||
#ifdef CONFIG_OF_CONTROL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enabling this config means, we wont be setting the mac address from OTP, is this what we want ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enabling CONFIG_OF_CONTROL means that we will retrieve the MAC address from the DTB if we did not find a valid MAC in the OTP.
|
||
#define VERSION_REG0_OFFSET 0x1002 | ||
#define VERSION_REG1_OFFSET 0x2002 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seeing as you've added this perhaps we could move all otp layout defines into here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
return 0; | ||
} | ||
int ft_board_setup(void *blob, bd_t *bd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whats the need for the weak ref, no one is going to override us right? Just define ft_board_setup and call fixup_wifi directly from it as we have no cpu setup to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed weak ref
77f2eb1
to
2a6812e
Compare
|
||
DECLARE_GLOBAL_DATA_PTR; | ||
|
||
static void fixup_wifi(void *blob) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we just keep this function to fix wifi mac addresses, and write different one to overwrite calibration data ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
#ifndef WINBOND_OTP_H | ||
#define WINBOND_OTP_H | ||
|
||
#define MAC_ADDR_LEN 6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing to do with this chip. It too can go to otp.h as it's related to layout?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|| check_otp_version(VERSION_REG1_OFFSET)) | ||
return; | ||
|
||
node = fdt_path_offset(blob, "wifi0"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be "wlan0" to keep in line with the interface names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see my comment on CreatorDev/openwrt#117
Verified that eth and wifi STA mac addresses are assigned properly. root@OpenWrt:/# hexdump -n 6 -v -e '/1 "%02X"' /proc/device-tree/uccp@18480000/m |
Signed-off-by: Avinash Tahakik <[email protected]> Signed-off-by: Francois Berder <[email protected]>
ethernet MAC address is stored in the OTP, read it and write it into dtb, so kernel can use updated MAC address Signed-off-by: Avinash Tahakik <[email protected]> Signed-off-by: Francois Berder <[email protected]>
The MAC address for Wifi STA and AP are read from the OTP, then written in the wifi driver node of the device-tree. Concerning calibration data, only DCXO is read from the OTP and overwrites the first byte of the calibration parameter in the device tree. Signed-off-by: Francois Berder <[email protected]>
The version of register 0 and 1 must be greater or equal to 1, otherwise do not attempt to read any data from the OTP. Signed-off-by: Francois Berder <[email protected]>
This connects #19.
This connects #15